use serde_derive::{Serialize, Deserialize};
use rust_admin2_common::{models::{AdminRoleRow as ModelRow}, json::JsonPager};
use sqlx::{postgres::{PgRow}, row::Row};
use crate::common::{Pool, models::BackendModel};

#[derive(Serialize, Deserialize, Debug)]
pub struct AdminRole;

impl BackendModel<ModelRow> for AdminRole {

    const TABLE_NAME: &'static str = "admin_roles";
    const FIELDS: &'static str = "id, name, status, remark, sort";

    fn get_row_filter(r: &PgRow) -> ModelRow {
        unfold_fields!(r, {
            id => i32,
            name => String,
            remark => String,
            status => i16,
            menus => String,
            sort => i32,
        })
    }
}

impl AdminRole {
    record_list!();
}
